layui.use(['form', 'layer', 'table', 'laytpl'], function () {
	var $ = layui.jquery,
		table = layui.table;

	window.active = {
		search: () => {
			var key = $(".searchVal").val();
			table.reload("tableListTable", {
				page: {
					curr: 1 //重新从第 1 页开始
				},
				where: {
					key: key //搜索的关键字
				}
			})
		},
		reload: () => {
			table.reload("tableListTable");
		},
		edit: (data) => {
			popEdit(data, 'page/goods/edit.html', ["1000px", "600px"])
		},
		del: (data) => {
			popDelete(data.name, 'goods', {
				id: data.id,
				task_id: data.task_id,
			});
		}
	}

	//表格外按钮操作
	$('.tableHead .layui-btn').on('click', function () {
		var type = $(this).data('type');
		active[type] ? active[type].call(this) : '';
	});
	//表格按钮操作
	table.on('tool(tableList)', function (obj) {
		var type = obj.event;
		active[type] ? active[type].call(this, obj.data) : '';
	});

})